﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;
using NickLee.Common;

namespace GPCSC.Web.sjs
{
    public partial class jjwtEdits : PageBase 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string sdf = Usual.f_querystringToString("newsid");
                //this.Button2.Attributes.Add("onclick", "return tj();");
                if (sdf != "" && sdf != null)
                {
                    f_bund(sdf);
                }
            }
        }
        protected void f_bund(string ids)
        {
            DataSet ds = new DataSet();
            Hashtable htable = new Hashtable();
            htable.Add("@ids", ids);
            ds = new SqlReadXml().ReaderDataSet("sel_wt_byids", htable);
            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    this.MtxtD_wtvalue.Value = ds.Tables[0].Rows[0]["wtvalue"].ToString();

                    this.MtxtD_wttex.Value = ds.Tables[0].Rows[0]["wttex"].ToString();
                    this.Button1.Visible = false;
                    this.Button2.Visible = false;
                }
            }
        }


        //已解决
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {

                Hashtable htable = new Hashtable();
                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
                Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                base.o_uiTable.Clear();
                base.o_uiTable = UIFactory.UIFactory_Get(this);
                SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();

                base.o_uiTable.Add("tjdate", DateTime.Now.ToString());

                base.o_uiTable.Add("jjdate", DateTime.Now.ToString());
                base.o_uiTable.Add("juvalue", "1");
                base.o_uiTable.Add("lgid", users.CL_USER_SOID.ToString());
                string types = this.types.Value.ToString();
                base.o_uiTable.Add("jutext", types);
                //dtable.databyhtables(base.o_uiTable, "add", "wts_table", "", "");
                dtable.databyhtables(base.o_uiTable, "add", "wts_table", "", "");

                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>showtable();</script>");
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }


        //未解决
        protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                Hashtable htable = new Hashtable();
                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
                Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                base.o_uiTable.Clear();
                MtxtD_wttex.Value = MtxtD_wttex.Value.Replace("\n","^");
                base.o_uiTable = UIFactory.UIFactory_Get(this);
                SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();

                base.o_uiTable.Add("tjdate", DateTime.Now.ToString());

                base.o_uiTable.Add("lgid", users.CL_USER_SOID.ToString());
                string types = this.types.Value.ToString();
                base.o_uiTable.Add("jutext", types);
                //base.o_uiTable.Add("juvalue", "1");
                base.o_uiTable.Add("juvalue", "0");
                string typ = this.type.Value.ToString();
                base.o_uiTable.Add("typ", typ);
                base.o_uiTable.Add("Postid", users.CL_POSTID_PK.ToString());
                dtable.databyhtables(base.o_uiTable, "add", "wts_table", "", "");

                //this.Response.Write("<script>alert('添加成功！');window.location.href='jjwtlist.aspx';</script>");
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>showtable();</script>");
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
    }
}